package org.darkforest.merchant.ajaxTemplete.impl;

import org.darkforest.enums.AjaxAlbumTypeEnum;
import org.darkforest.merchant.ajaxTemplete.AlbumAjaxPage;

/**
 * Created by valentina on 15/3/19.
 * 添加商品第二步商品主图返回code
 */
public class GoodsStep2ImageAlbum extends AlbumAjaxPageTemplete implements AlbumAjaxPage{

    public GoodsStep2ImageAlbum() {
        this.insertType = AjaxAlbumTypeEnum.IMAGE.getText();
    }

    @Override
    protected String getScriptCode() {
        String tpl = "";
        tpl += "<script type=\"text/javascript\">";
        tpl += "$(document).ready(function(){";

        tpl += "    $('.demo').ajaxContent({" +
                "       event:'click'," +
                "       loaderType:'img'," +
                "       loadingMsg:'" + basePath + "/resources/images/loading.gif'," +
                "       target:'#demo'" +
                "   });";
        //选择相册触发的js
        tpl += "    $('#jumpMenu_" + insertType + "').change(function(){" +
                "       var url = '" + getAjaxUrl() + "&albumId='+$('#jumpMenu_" + insertType + "').val();" +
//                    "       alert(\"-----\"+url);" +
                "       $('#select_submit_" + insertType + "').attr('href',url);" +
                "        $('.sample_demo').ajaxContent({" +
                "            event:'click', " +
                "            loaderType:'img'," +
                "            loadingMsg:'" + basePath + "/resources/images/loading.gif'," +
                "            target:'#demo'" +
                "        });" +
                "       $('#select_submit_" + insertType + "').click();" +
                "   });";

        tpl += "});" +
                "</script>";
        return tpl;
    }
}
